var express = require('express');
var router = express.Router();
var path = require('path');
var connection = require('../connectDB');

/* GET home page. */
router.get('/', function (req, res, next) {
    let pathUrl = path.join(__dirname + '.\/../../views/lxcjifenshangcheng.html');
    res.sendFile(pathUrl);

});

router.post('/a', async function (req, res, next) {
    var lxc = await fun1();
    res.send(lxc);

});


function fun1() {
   return new Promise((a,b) => {
        connection.query('SELECT * FROM `goods` limit 0,3', (error, results, fields) => {
            if (!error) {
                a(JSON.stringify(results))
            }
        })
    })
}




















module.exports = router;